package com.cy.mall.service.brand.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cy.mall.dao.mapper.brand.BrandMapper;
import com.cy.mall.model.PageBean;
import com.cy.mall.model.domain.brand.Brand;
import com.cy.mall.model.query.brand.BrandListQuery;
import com.cy.mall.model.vo.brand.BrandDetailVO;
import com.cy.mall.model.vo.brand.BrandListVO;
import com.cy.mall.model.vo.brand.EnableBrandListVO;
import com.cy.mall.service.BaseService;
import com.cy.mall.service.brand.BrandService;

/**
 * 品牌 服务类BrandService 
 *
 * @author tanyilin
 *
 * @create 2019年1月23日 下午6:10:17
 */
@Service
public class BrandServiceImpl extends BaseService implements BrandService {

	@Autowired
	private BrandMapper brandMapper;

	@Override
	public PageBean<BrandListVO> selectBrandList(BrandListQuery query) {
		int total = brandMapper.selectBrandListCount(query);
		List<BrandListVO> list = new ArrayList<>();
		if(total > 0) {
			query.startPage();
			list = brandMapper.selectBrandList(query);
		}
		return new PageBean<>(list, total);
	}

	@Override
	public BrandDetailVO selectBrandDetail(Long brandId) {
		BrandDetailVO brandDetail = brandMapper.selectBrandDetail(brandId);
		state(brandDetail != null, "品牌详情异常");
		return brandDetail;
	}

	@Override
	public List<EnableBrandListVO> allEnableBrandList() {
		List<EnableBrandListVO> list = brandMapper.selectAllEnableBrandList();
		return list;
	}
	
	
	
}
